package com.ctd.springframework.core.io;

import com.ctd.springframework.util.ClassUtils;

/**
 * todo 虚位以待，请打造属于自己的品牌
 * DefaultResourceLoader
 *
 * @author chentudong
 * @date 2019/3/26 0:32
 */
public class DefaultResourceLoader implements ResourceLoader {
    private ClassLoader classLoader;

    /**
     * 加载classloader
     */
    public DefaultResourceLoader() {
        this.classLoader = ClassUtils.getDefaultClassLoader();
    }

    /**
     * Create a new DefaultResourceLoader.
     *
     * @param classLoader the ClassLoader to load class path resources with, or {@code null}
     *                    for using the thread context class loader at the time of actual resource access
     */
    public DefaultResourceLoader(ClassLoader classLoader) {
        this.classLoader = classLoader;
    }

    /**
     * getResource
     *
     * @param location location
     * @return Resource
     */
    @Override
    public Resource getResource(String location) {
        return null;
    }

    /**
     * 获取ClassLoader
     *
     * @return ClassLoader
     */
    @Override
    public ClassLoader getClassLoader() {
        return (this.classLoader != null ? this.classLoader : ClassUtils.getDefaultClassLoader());
    }
}
